const { DataTypes, Model } = require('sequelize')
const sequelize = require('../config/database');
const Tags = require('./Tags');
class Category extends Model { }

Category.init({
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    allowNull: false,
    autoIncrement: true,
    comment: '记录ID'
  },
  category_name: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '分类名称'
  },
  rmk: {
    type: DataTypes.STRING,
    allowNull: true,
    comment: '分类备注'
  },
  seq: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '排序序号'
  },
  stats: {
    comment: '启禁状态',
    type: DataTypes.INTEGER,
    allowNull: false,
    validate: {
      isIn: [[0, 1, 2]] // 限制值为 0: 待启用、1:已启用 2:已禁止
    },
    defaultValue: 1 // 默认值为 0（未删除）
  },
  ctime: {
    comment: "创建时间",
    type: DataTypes.BIGINT,
    allowNull: false,
    defaultValue: () => new Date().getTime()
  },
  mtime: {
    comment: '更新时间',
    type: DataTypes.BIGINT,
    allowNull: false,
    defaultValue: () => new Date().getTime()
  },
}, {
  sequelize,
  modelName: 'Category'
})
module.exports = Category;